using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using DataTransferObject;
using Business;


namespace Presentation.UserControlls
{
    public partial class UC_SachConLai : UserControl
    {
        clsSachDTO sachDTO = new clsSachDTO();
        clsSachBUS sachBUS = new clsSachBUS();
        clsThuKhoBUS ThuKhoBUS = new clsThuKhoBUS();

        DataTable tbl = new DataTable();
        int tongcong;

        public UC_SachConLai()
        {
            InitializeComponent();
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
            DialogResult dlg = new DialogResult();
            dlg = DevComponents.DotNetBar.MessageBoxEx.Show("Bạn có muốn thoát không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dlg == DialogResult.Yes)
            {
                this.ParentForm.Close();

            }
        }

        private void HienThiListView(DataTable tbl)
        {

            ListViewItem lvwitem = new ListViewItem();
            lvwthongkesachdamuon.Items.Clear();
            foreach (DataRow dr in tbl.Rows)
            {
                string trangthai = dr["TrangThai"].ToString();
                if (trangthai == "Chưa Mượn")
                {
                    tongcong = tongcong + 1;
                    lvwitem = new ListViewItem();
                    lvwitem.Text = dr["DKCB"].ToString();

                    //lvwitem.SubItems.Add(dr["DKCB"].ToString());
                    lvwitem.SubItems.Add(dr["TenTuaSach"].ToString());
                    lvwitem.SubItems.Add(dr["Gia"].ToString());
                    //lvwitem.SubItems.Add(dr["TrangThaiMT"].ToString());
                    lvwthongkesachdamuon.Items.Add(lvwitem);
                }

            }


        }

        private void UC_SachConLai_Load(object sender, EventArgs e)
        {
           
            tbl =ThuKhoBUS.ThuKhoThongKeSachConTrongKho();

          //  tongcong = 0;

            HienThiListView(tbl);
            lbltongcong.Text = Convert.ToString(tongcong);
        }
    }
}
